<template>
  <div class="handleTicket">
    <createComments></createComments>
  </div>
</template>
<script>
import { Dialog } from 'vant';
import createComments from '@/components/createComments'
export default {
  data(){
    return{
      value:'',
      checked:true,
      user_list:[],
    }
  },
  components:{
    createComments,
  },
  methods:{
    submit(data){
      Object.assign(data, this.$route.query.data)
      if(this.$route.query.incident == 'handleTicket'){//处理工单事件
        if(this.$route.query.attribute_type_id == '2'){//当前处理工单操作是拒绝工单
          Dialog.confirm({
            title: '提示',
            message: '拒绝后流程将结束，确认拒绝吗?'
          }).then(() => {
            this.handleTicket(data)
          }).catch(() => {
            
          });
        }else{
          this.handleTicket(data)
        }
      }else{//加签完成事件
        this.addNode(data)
      }
    },

    handleTicket(data){
      data.transition_id = this.$route.query.transition_id
      this.$store.dispatch("api_handle_ticket_action", data).then(resp => {
        if(resp.status == 200){
          this.$router.go(-1)
          this.$toast.success('处理工单成功');
        }
      }).catch(error => {
        console.log(error);
        this.$toast.fail('处理工单失败，请稍后重试');
      });
    },
    addNode(data){
      this.$store.dispatch("api_add_node_end", data).then(resp => {
        if(resp.status == 200){
          this.$router.go(-1)
          this.$toast.success('处理工单完成');
        }
      }).catch(error => {
        console.log(error);
        this.$toast.fail('处理工单失败，请稍后重试');
      });
    }
  },

}
</script>

<style lang="less" scoped >
.handleTicket{
  position: absolute;
  top:0;
  bottom:0;
  width: 100%;
  background: #fff;
}
</style>